package readfile;

import java.util.Scanner;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class ReadStringFile 
{
	//private Scanner fileIn;
	private File sourcefile;
	private String lineOfFile;
	private BufferedReader fastReader;
	
	public ReadStringFile()
	{
		super();
		//fileIn = null;
		sourcefile = null;
		lineOfFile = null;
		fastReader = null;
	}
	
	public ReadStringFile(String fileName)
	{
		try
		{
			sourcefile = new File(fileName);
			fastReader = new BufferedReader(new FileReader(sourcefile));
			//fileIn = new Scanner(sourcefile);
		}
		catch(FileNotFoundException nf)
		{
			nf.getMessage();
			System.out.println("\nError: File not found.\n");
		}
	}
	
	public boolean hasLine() throws IOException
	{
		//return fileIn.hasNextLine();
		return fastReader.ready();
	}
	
	public String readLine() throws IOException
	{
		lineOfFile = fastReader.readLine();
		//lineOfFile = fileIn.nextLine();
		return lineOfFile.trim();
	}
	
	public void closeStream() throws IOException
	{
		fastReader.close();
	}
	
	public String[] tokenizeLine() throws IOException
	{
		lineOfFile = fastReader.readLine();
		//lineOfFile = fileIn.nextLine();
		
		return lineOfFile.split(" ");
	}
}
